<template>
	<view id="page">
		<nav-bar :navH="navH" :isTabar="false" :isHome="false" :pageName="title"></nav-bar>
		<view class="integral">
			<view class="banner">
				<image src="../../static/41.jpg" mode="widthFix" lazy-load="true"></image>
				<view class="info">
					<view class="inte">
						<text style="margin-bottom: 15upx; font-size: 60upx; font-weight: bold;">{{totalInte}}</text>
						<text>我的积分</text>
					</view>
					<navigator url="../qiandao/index" hover-class="none" class="btn">我要签到</navigator>
				</view>
			</view>
			<view class="inte-d">
				<text class="h">积分明细</text>
				<view class="t flex">
					<text>积分</text>
					<text>类型</text>
					<text>时间</text>
				</view>
				<block v-if="hasRes">
					<block v-for="(it, k) in lists" :key="k">
						<view class="d flex">
							<text>+{{it.integral}}</text>
							<text>{{it.typename}}</text>
							<text>{{it.addtime}}</text>
						</view>
					</block>
				</block>
				<view class="nocont" v-else>暂无内容</view>
				<view class="nomore" v-if="isLoad"><image src='../../static/nomore_img.png' mode="widthFix"></image><text>没有更多了~</text></view>
			</view>
		</view>
	</view>
</template>

<script>
	import app from '../../common/index.js'
	export default {
		data() {
			return {
				title: '积分明细',
				navH: null,
				userInfo: {},
				hasRes: true,
				isLoad: false,
				page: 1,
				size: 10,
				lists: [],
				totalInte: '',  // 总积分
			}
		},
		onLoad() {
			this.navH = this.$store.state.navHeight;
			// 获取本地用户信息
			this.userInfo = uni.getStorageSync('uinfo');
			this.getIntegral();
		},
		// 下拉刷新
		onPullDownRefresh() {
			this.page = 1;
			this.lists = [];
			// 获取本地用户信息
			this.userInfo = uni.getStorageSync('uinfo');
			this.getIntegral()
			uni.stopPullDownRefresh();
		},
		// 上划加载
		onReachBottom() {
			if(!this.isLoad) {
				this.page = this.page + 1;
				this.getIntegral();
			}
		},
		// 分享转发
		onShareAppMessage() {
			return {
				title: '爱美指南针',
				path: 'pages/index/index',
			}
		},
		methods: {
			/**
			 * @des 获取积分明细
			 */
			getIntegral() {
				app.request({
					url: 'entry/wxapp/IntegralList',
					data: {
						user_id: this.userInfo.id,
						page: this.page,
						pagesize: this.size,
					}
				}, (ret) => {
					let d = ret.data, tmpData = this.lists, len = d.data.length;
					this.totalInte = d.total_integral;
					if (d.total > 0) {
						this.hasRes = true;
						this.lists = tmpData.concat(d.data);
						this.isLoad = len < this.size ? true : false;
					} else {
						this.hasRes = false;
					}
				})
			}
		}
	}
</script>

<style>
	.integral .banner {position: relative;}
	.integral .banner .info {position: absolute; top: 18%; left: 50%; transform: translateX(-50%);}
	.integral .banner .info .inte {margin: 0 auto;}
	/* .integral .banner .info .inte::before {content: ''; position: absolute; top: -15upx; width: 150upx; height: 150upx; border-radius: 100%; border: 15upx solid #fff; transform: translateX(-50%);}
	.integral .banner .info .inte::after {content: ''; position: absolute; top: -28upx; width: 178upx; height: 178upx; border-radius: 100%; border: 14upx solid rgba(255,255,255,.6); transform: translateX(-50%);} */
	.integral .banner .info text {display: block; color: #fff;}
	.integral .banner .info .btn {width: 220upx; height: 70upx; border-radius: 5px; margin-top: 30upx; line-height: 70upx; color: #8257e6; background-color: #fff;}
	.inte-d {position: absolute; left: 50%; transform: translateX(-50%); width: 95%; margin: -30upx auto 0; border-radius: 5px; background-color: #fff;}
	.inte-d .h {display: block; padding: 30upx 20upx; text-align: left; font-size: 32upx;}
	.flex {display: flex;}
	
	.inte-d .t {padding: 20upx 0; border: 1px solid #82d7d0; background-color: #e6f7f6;}
	.inte-d .t text {flex: 1; color: #098c81;}
	.inte-d .d {padding: 20upx 0; border-bottom: 1px solid #eee;}
	.inte-d .d text {flex: 1; color: #666;}
	
	.nomore {background-color: #f4f4f4;}
</style>
